package com.mindata.blockchain.core.service.LogMessage;
import com.mindata.blockchain.block.LogMessage.LogMessageEntity;
import com.mindata.blockchain.core.controller.LogMessageController.LogController;
import com.mindata.blockchain.core.model.MessageEntity;
import com.mindata.blockchain.core.repository.MessageRepository;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/logEnter")
public class LogMessageByIdService {
        @Resource
        MessageRepository messageRepository;
        @Resource
        LogController logController;


        @RequestMapping("/logMessage")
        public String printLogById(@RequestParam("id") long id){


            String str = "";
            MessageEntity messageEntity = messageRepository.findById(id);
            String messageId = messageEntity.getMessageId();
            List<LogMessageEntity> logMessageList = logController.printLog(messageId);
            for(LogMessageEntity logMessage1 : logMessageList){
                str = str + logMessage1;
            }

            return str;
        }

}
